{% extends "manage/manage_base.html" %}
{% load i18n %}
{% load lfs_tags %}
{% load lfs_manage_tags %}

{% block title %}{% trans "Manage Product" %}{% endblock %}

{% block help_link %}user/management/catalog/products.html{% endblock %}
{% block section %}manage-product{% endblock %}

{% block javascript %}
    <script type="text/javascript" src="{{ STATIC_URL }}js/lfs.manage.product.js"></script>
    <script type="text/javascript">
        var MANUFACTURERS_AJAX_URL = '{% url lfs_manufacturers_ajax %}';
    </script>
{% endblock %}

{% block left_slot %}
    <form action="{% url lfs_set_product_name_filter %}"
          method="post">

        <input type="text"
               name="name"
               class="refresh-on-keyup"
               style="width:100%"
               onKeyPress="return disable_enter_key()"
               value="{{ name_filter_value }}" />

        <input type="hidden"
               name="product-id"
               value="{{ product.id }}" />
    </form>

    <div id="pages-inline">
        {{ pages_inline|safe }}
    </div>

    <div class="navigation-body"
         id="selectable-products-inline">
        {{ selectable_products }}
    </div>
{% endblock %}

{% block content %}
    <div id="product">
        <div class="site-actions">
            {% if product.is_variant %}
                <a class="overview"
                   href="{% url lfs_manage_product product.parent.id %}">
                    {% trans "Base Article" %}
                </a>
            {% endif %}

            <a class="add"
               href="{% url lfs_manage_add_product %}?came_from={% url lfs_manage_product product.id %}">
                {% trans 'Add Product' %}
            </a>

            <a class="delete delete-link"
               href="{% url lfs_manage_delete_product product.id %}"
               dialog_message='{% trans "Do you really want to delete this product?" %}'>
               {% trans 'Delete Product' %}
            </a>

            <a class="view popup-link"
               href="{% url lfs_manage_product_by_id product.id %}">
               {% trans 'View Product' %}
            </a>

            <a class="goto"
               href="{% url lfs_manage_product_by_id product.id %}">
               {% trans 'Goto Product' %}
            </a>

            {% if not product.is_variant %}
                <form style="display:inline; padding-left:15px"
                      action="{% url lfs_change_product_subtype product.id %}"
                      method="post">

                    {% csrf_token %}
                    {{ form.sub_type }}

                    <input type="submit"
                           value="{% trans 'Change' %}" />
                </form>
                <img class="ajax-loading" src="{{ STATIC_URL }}img/ajax-loader.gif" alt="" style="padding:0; margin:0" />
            {% endif %}
        </div>
        <div id="product-tabs">
            <ul>
                <li>
                    <a href="#data">{% trans "Data" %}</a>
                </li>

                {% if not product.is_variant %}
                    <li><a href="{% url lfs_product_categories_tab product.id %}">{% trans 'Categories' %}</a></li>
                {% endif %}

                <li><a href="#images">{% trans 'Images' %}</a></li>
                <li><a href="#attachments">{% trans 'Attachments' %}</a></li>

                {% if product.is_product_with_variants %}
                    <li class="ui-tabs-nav-item"><a href="{% url lfs_manage_product_variants_tab product.id %}">{% trans 'Variants' %}</a></li>
                {% endif %}

                <li><a href="{% url lfs_manage_product_accessories_tab product.id %}">{% trans 'Accessories' %}</a></li>
                <li><a href="{% url lfs_manage_product_related_products_tab product.id %}">{% trans 'Related Products' %}</a></li>
                <li><a href="#stock">{% trans 'Stock' %}</a></li>
                <li><a href="#seo">{% trans 'SEO' %}</a></li>
                <li><a href="#portlets">{% trans 'Portlets' %}</a></li>
                <li><a href="#properties">{% trans 'Properties' %}</a></li>
            </ul>

            <div id="data">
                {{ product_data|safe }}
            </div>

            <div id="images">
                {{ images|safe }}
            </div>

            <div id="attachments">
                {{ attachments|safe }}
            </div>

            <div id="stock">
                {{ stock|safe }}
            </div>

            <div id="seo">
                {{ seo|safe }}
            </div>

            <div id="properties">
                {{ properties|safe }}
            </div>

            <div id="portlets">
                {{ portlets|safe }}
            </div>
        </div>
    </div>
{% endblock %}
